package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ModuleChangeLogDao;
import com.sugon.entity.ModuleChangeLogEntity;
import com.sugon.service.ModuleChangeLogService;
import com.sugon.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 模具车间变更记录Service实现类
 *
 * @author sugon
 * @date 2020-01-07 14:37:56
 */
@Service("moduleChangeLogService")
public class ModuleChangeLogServiceImpl implements ModuleChangeLogService {
    @Autowired
    private ModuleChangeLogDao moduleChangeLogDao;

    @Override
    public ModuleChangeLogEntity queryObject(String id) {
        return moduleChangeLogDao.queryObject(id);
    }

    @Override
    public List<ModuleChangeLogEntity> queryList(Map<String, Object> map) {
        return moduleChangeLogDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return moduleChangeLogDao.queryTotal(map);
    }

    @Override
    public int save(ModuleChangeLogEntity moduleChangeLog) {
        moduleChangeLog.setId(RandomUtil.randomString(32));
        moduleChangeLog.setAuthor(ShiroUtils.getUserId());
        moduleChangeLog.setAuthorDate(new Date());
        return moduleChangeLogDao.save(moduleChangeLog);
    }

    @Override
    public int save(String subShopOld, String subShopNow, String moduleCode, String moduleNo) {
        ModuleChangeLogEntity mcl = new ModuleChangeLogEntity();
        mcl.setModuleCode(moduleCode);
        mcl.setModuleNo(moduleNo);
        mcl.setSubShopOld(subShopOld);
        mcl.setSubShopNow(subShopNow);
        return save(mcl);
    }

    @Override
    public int update(ModuleChangeLogEntity moduleChangeLog) {
        return moduleChangeLogDao.update(moduleChangeLog);
    }

    @Override
    public int delete(String id) {
        return moduleChangeLogDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return moduleChangeLogDao.deleteBatch(ids);
    }
}
